//
//  LSZMutualProblemManager.m
//  PartyClassCloud
//
//  Created by 梁素珍 on 2018/8/15.
//  Copyright © 2018年 九酷. All rights reserved.
//

#import "LSZMutualProblemManager.h"

@implementation LSZMutualProblemManager
-(id)initWithMutualProblem :(NSArray *)array
{
    self = [super init];
    if (self) {
        self.mutMgArray  = [[NSMutableArray alloc]init];
        NSMutableArray * arrayMut = [[NSMutableArray alloc]init];
        for (NSDictionary * diction in array) {
            LSZMutualProblemMg * mg = [[LSZMutualProblemMg alloc]init];
            mg.solved = NullStringjudgment(NSStr(diction[@"solved"]));
            mg.content = NullStringjudgment(NSStr(diction[@"content"]));
            mg.publishTime = NullStringjudgment(NSStr(diction[@"publishTime"]));
            mg.id_id = NullStringjudgment(NSStr(diction[@"id"]));
 
            if ([[diction allKeys] containsObject:@"customerId"]) {
                mg.customerId = NullStringjudgment(NSStr(diction[@"customerId"]));
            }else{
                mg.customerId = @"";
            }
            if ([[diction allKeys] containsObject:@"customerName"]) {
                mg.customerName = NullStringjudgment(NSStr(diction[@"customerName"]));
            }else{
                mg.customerName = @"";
            }
            if ([[diction allKeys] containsObject:@"questionId"]) {
                mg.questionId = NullStringjudgment(NSStr(diction[@"questionId"]));
            }else{
                mg.questionId = @"";
            }
            
            if ([[diction allKeys] containsObject:@"customerUrl"]) {
                mg.headUrl = [NSString stringWithFormat:@"%@%@",URLTotalWeb,diction[@"customerUrl"]];
            }else{
                mg.headUrl = @"";
            }
            if ([[diction allKeys] containsObject:@"coverUrl"]) {
                NSLog(@"%@>>>>>>>",diction[@"coverUrl"]);
                if ((NullStringjudgment(NSStr(diction[@"coverUrl"]))).length == 0  ) {
                    mg.headUrlArray = [[NSArray alloc]init];
                }else{
                    NSArray *array = [diction[@"coverUrl"] componentsSeparatedByString:@","]; //从字符A中分隔成2个元素的数组
                    NSMutableArray * mutArray = [NSMutableArray array];
                    for (NSString * strUrl in array) {
                        NSString * str = [NSString stringWithFormat:@"%@%@",URLTotalWeb,strUrl];
                        [mutArray addObject:str];
                    }
                    mg.headUrlArray = mutArray;
                }
                //                mg.headUrl = NullStringjudgment(NSStr(diction[@"headUrl"]));
            }else{
                mg.headUrlArray = [[NSArray alloc]init];
            }
            
            
            if ([[diction allKeys] containsObject:@"publish"]) {
                mg.publish = NullStringjudgment(NSStr(diction[@"publish"]));
            }else{
                mg.publish = @"";
            }
            if ([[diction allKeys] containsObject:@"answerCount"]) {
                mg.answerCount = NullStringjudgment(NSStr(diction[@"answerCount"]));
            }else{
                mg.answerCount = @"";
            }
            
            if ([[diction allKeys] containsObject:@"customerId"]) {
                mg.customer_id = diction[@"customerId"];
            }else{
                mg.customer_id = @"";
            }
            if ([[diction allKeys] containsObject:@"customer"]) {
                NSDictionary * dicCustomer = diction[@"customer"];
                if ([[dicCustomer allKeys] containsObject:@"realName"]) {
                    mg.realName = NullStringjudgment(NSStr(dicCustomer[@"realName"]));
                }else{
                    mg.realName = @"";
                }
               
              
            }
            [arrayMut addObject:mg];
        }
        self.mutMgArray = arrayMut;
    }
    return self;
}
@end

@implementation LSZMutualProblemMg
@end
